package com.baomidou.ant.service.impl;

import com.baomidou.ant.entity.RealName;
import com.baomidou.ant.mapper.RealNameMapper;
import com.baomidou.ant.service.IRealNameService;
import com.baomidou.ant.utils.IdCardUtils;
import com.baomidou.ant.utils.compareDate;
import com.baomidou.ant.vo.Request.RequestMyRealNameVo;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author jobob
 * @since 2021-03-24
 */
@Service
public class RealNameServiceImpl extends ServiceImpl<RealNameMapper, RealName> implements IRealNameService {

    @Override
    public boolean putMyRealName(RequestMyRealNameVo vo) {
        QueryWrapper<RealName> queryWrapper=new QueryWrapper<>();
        queryWrapper.eq("id_card",vo.getIdCard());
        RealName realName=getOne(queryWrapper);
        if(realName!=null){
            return false;
        }
        RealName real=new RealName();
        BeanUtils.copyProperties(vo,real);
        real.setEMail(vo.getEMail());
        /*real.setUserAge(IdCardUtils.age(vo.getIdCard()));*/
        save(real);
        return true;
    }

}
